-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hackathon 5th No.63 PhyCRNet: Physics-informed Convolutional-Recurrent Network for Solving Spatiotemporal PDEs #557
Conversation
Thanks for your contribution! |
更新使用 PaddleScience套件,增加ppsci.arch.PhyCRNet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to align with paper
|
||
## 5. 结果展示 | ||
|
||
PhyCRNet 案例针对 epoch=200 和 learning\_rate=1e-4 的参数配置进行了实验,结果返回Loss为 17.86。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compute the error
error = frobenius_norm(np.array(ten_pred)-np.array(ten_true)) / frobenius_norm(
np.array(ten_true))
print('The predicted error is: ', error)
u_pred = output[:-1, 0, :, :].detach().cpu().numpy()
u_pred = np.swapaxes(u_pred, 1, 2) # [h,w] = [y,x]
u_true = truth[:, 0, :, :]
t_true = np.linspace(0, 2, 1001)
t_pred = np.linspace(0, 2, time_steps)
plt.plot(t_pred, u_pred[:, 32, 32], label='x=32, y=32, CRL')
plt.plot(t_true, u_true[:, 32, 32], '--', label='x=32, y=32, Ref.')
plt.xlabel('t')
plt.ylabel('u')
plt.xlim(0, 2)
plt.legend()
plt.savefig(fig_save_path + "x=32,y=32.png")
plt.close("all")
# plt.show()
# plot train loss
plt.figure()
plt.plot(train_loss, label = 'train loss')
plt.yscale('log')
plt.legend()
plt.savefig(fig_save_path + 'train loss.png', dpi = 300)
科学计算类论文复现,更关注 物理error和最后的物理场效果,参考原文代码复现error和对比图
(可以从checkpoint加载模型直接eval,不需要重新训练)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need a-RMSE plot for t in [0,4]
# initialize logger | ||
logger.init_logger("ppsci", f"{OUTPUT_DIR}/train.log", "info") | ||
# set training hyper-parameters | ||
EPOCHS = 200 if not args.epochs else args.epochs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2000
return result_dict["loss"] | ||
|
||
|
||
def output_graph(model, input_dataset, fig_save_path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,273 @@ | |||
# Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FN_2d_solver_[HighOrder].py
FitzHugh- Nagumo RD 方程数据生成代码需要补齐
np.array(ten_pred) - np.array(ten_true) | ||
) / functions.frobenius_norm(np.array(ten_true)) | ||
|
||
print("The predicted error is: ", error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error要求达到:源码,论文(1e-3)取较大值
--8<-- | ||
``` | ||
|
||
### 3.7 模型训练与评估 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
self.input_channels = input_channels | ||
self.hidden_channels = hidden_channels | ||
self.hidden_kernel_size = 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3是怎么来的?
self.input_kernel_size = input_kernel_size | ||
self.input_stride = input_stride | ||
self.input_padding = input_padding | ||
self.num_features = 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4是怎么来的?
class loss_generator(nn.Layer): | ||
"""Loss generator for physics loss""" | ||
|
||
def __init__(self, dt=(10.0 / 200), dx=(20.0 / 128)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
默认值删掉
if __name__ == "__main__": | ||
# grid size | ||
M, N = 128, 128 | ||
n_simu_steps = 30000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
40000
layer_state_dict = paddle.load("output/phycrnet.pdparams") | ||
model.set_state_dict(layer_state_dict) | ||
model.register_output_transform(None) | ||
output_graph(model, input_dict_val, fig_save_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
input_dict_val进行修改,尝试完成时间变量t,从0s到4s的u_predict和u_true的对比,以及a-RMSE计算
暂时关闭 |
PR types
Others
PR changes
Others
Describe
PaddlePaddle/Paddle#57262
Loss精度
运行 200 次截图
torch
paddle